package com.cenntro.nearr.interceptor;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.servlet.HandlerInterceptor;
import org.springframework.web.servlet.ModelAndView;

import com.cenntro.nearr.redis.IRedisService;

//@WebServlet
public class MyInterceptor implements HandlerInterceptor {
	
	private Logger LOG = LoggerFactory.getLogger(MyInterceptor.class);
	
	@Resource
	private IRedisService iredisService;
	
	@Override
	public boolean preHandle(HttpServletRequest req, HttpServletResponse arg1, Object arg2) throws Exception {
//		String token = req.getParameter("token");
//		if (StringUtils.isBlank(token)){
//			arg1.sendRedirect("/login.html");
////			return false;
//		}
//		String t = iredisService.get(token);
//		if(!token.equals(t)){
//			arg1.sendRedirect("/login.html");
//			return false;
//		}
		LOG.info("#############");
		System.out.println(iredisService);
		return Boolean.TRUE;
	}
	@Override
	public void afterCompletion(HttpServletRequest arg0, HttpServletResponse arg1, Object arg2, Exception arg3)
			throws Exception {
		
	}
	
	@Override
	public void postHandle(HttpServletRequest arg0, HttpServletResponse arg1, Object arg2, ModelAndView arg3)
			throws Exception {
		// TODO Auto-generated method stub
		
	}
}
